<?php
namespace Admin\Model;
use Think\Model;
class UserModel extends Model {
    //登录页面账号密码格式验证
    protected $_validate = array(
        array('username','require','登录账户必须'),
        array('password','require',"登录密码必须"),
        array('username','/^[a-z0-9_-]{6,18}$/','登录账户格式错误','regex'),
        array('password','/^[a-z0-9_-]{6,18}$/','登录密码格式错误','regex')
    );  
    function checkUserPwd(){
        $password = $this->where('username="'.$this->username.'"')
                                    ->select();
        if(!empty($password)){
            if($password['activeflag'] == 0){
                if($password[0]['password'] === MD5(MD5($this->password).'zdsoft')){
                    cookie('logIn',$password[0]['username'],3600);
                    session('logIn',array('uid'=>$password[0]['id'],
                                                    'username' =>$password[0]['username']
                                                    ));
                    return array('status'=>"1",'info'=>"验证通过",'url'=>U('Admin/AdminIndex/index'));
                }else{
                    return  array('status'=>"0",'info'=>"账号密码不匹配",);      //密码不匹配
                }
            }else{
                    return array('status'=>"0",'info'=>"账户未激活");      //账号未激活
            }
    }else{
        return array('status'=>"0",'info'=>"未查询到相关账户,请注册一个账号!!");
    }
}
}
?>